package com.robusta.spreadsheet.model.impl;

import com.robusta.spreadsheet.model.Cell;
import com.robusta.spreadsheet.model.HeaderCell;
import com.robusta.spreadsheet.model.Row;

/**
 */
public class RobustaCell implements Cell {
    private org.apache.poi.ss.usermodel.Cell cell;
    private HeaderCell headerCell;
    private Row parent;

    protected RobustaCell(Row parent, org.apache.poi.ss.usermodel.Cell cell, HeaderCell headerCell) {
        this.parent = parent;
        this.cell = cell;
        this.headerCell = headerCell;
    }

    @Override
    public String getValue() {
        return cell.getStringCellValue();
    }

    @Override
    public HeaderCell getHeader() {
        return headerCell;
    }

    @Override
    public Row owner() {
        return parent;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("RobustaCell");
        sb.append("{value=").append(cell.getStringCellValue());
        sb.append(", headerText=").append(headerCell.getText());
        sb.append('}');
        return sb.toString();
    }
}
